﻿using ExampleService.VolcanoEngine.SDK.Provider;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace ExampleService.Host.Controllers
{
    [Route("api/translation")]
    [ApiController]
    public class TranslationDemoController : ControllerBase
    {
        private readonly TranslationTextService translationTextService;

        public TranslationDemoController(TranslationTextService translationTextService)
        {
            this.translationTextService = translationTextService;
        }

        [HttpGet("sync")]
        [AllowAnonymous]
        public string GetTranslationTestAsync(string input)
        {
            var client = new VolcanoEngine("xx", "xx==");
            var result = client.translateText($@"{input}", "zh", "ko");

            Console.WriteLine(result); // 输出：世界你好
            return result;
        }

        [HttpGet("async")]
        [AllowAnonymous]
        public async Task<string> GetTranslationDemoAsync(string input)
        {

            var client = new VolcanoEngineV2("ss", "ss==");
            var result = await client.TranslateTextAsync($@"{input}", "zh", "ko");

            Console.WriteLine(result); // 输出：世界你好
            return result;
        }


        [HttpGet("async/sdk")]
        [AllowAnonymous]
        public async Task<string> GetTranslationSDKAsync(string input)
        {
            return await translationTextService.TranslateTextAsync($@"{input}", "en");
        }
    }
}
